<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">     
        <input type="text" v-model="data">
        <input type="button" value="点赞" v-on:click="data++">
        <button v-on:click="cancel">取消</button>
        <h1>{{name}},非常帅,有{{data}}人为他点赞</h1>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        let vm=new Vue({
            el:"#app",//绑定元素
            data:{//绑定数据
                name:"张三",
                data:2               
            },
            methods:{//封装方法
                cancel(){
                    if(this.data>0){
                        this.data--;
                    }                    
                }
            }           
        });
    </script>
</body>
</html>